package client;

import com.lry.proxy.Proxy;
import com.lry.proxy.ProxyFactory;
import com.lry.proxy.ProxyType;
import com.lry.router.RouterFactory;
import com.lry.router.RouterType;
import com.lry.rpc.config.RpcReferenceBean;
import com.lry.rpc.netty.client.RpcClient;
import impl.TestService;

public class Client {

    public static void main(String[] args) throws InterruptedException {

        RpcClient rpcClient = new RpcClient();

        RpcReferenceBean rpcReferenceBean = RpcReferenceBean.buildRpcReferenceBean(TestService.class);

        rpcClient.subscribeService(rpcReferenceBean);

        rpcClient.start();

        Thread.sleep(1000);
        Proxy proxy = ProxyFactory.getProxy(ProxyType.CGLIB, RouterFactory.getRouter(RouterType.RANDOM),null,new String[]{"toString"},"","");
        TestService testService = proxy.getProxy(TestService.class,"");
        System.out.println(testService.sayHello("lry"));
    }

}
